package com.zzb.weixin.model.msg.basic;

import org.w3c.dom.Document;
import org.w3c.dom.Element;

import com.zzb.weixin.constant.WXXmlElementName;
import com.zzb.weixin.json.JsonObject;

public class EncryptMsg extends Msg{
	private String encrypt;
	private String msgSignature;
	private String timeStamp;
	private String nonce;
	public EncryptMsg() {
	}
	public EncryptMsg(Document document) {
		this.document = document;
		this.read();
	}
	@Override
	public Element write() {
		Element xml = document.createElement(WXXmlElementName.XML);
		Element encryptElement = document
				.createElement(WXXmlElementName.ENCRYPT);
		encryptElement.setTextContent(this.encrypt);
		Element msgSignatureElement = document
				.createElement(WXXmlElementName.MSG_SIGNATURE);
		msgSignatureElement.setTextContent(this.msgSignature);
		Element timeStampElement = document
				.createElement(WXXmlElementName.TIME_STAMP);
		timeStampElement.setTextContent(this.timeStamp);
		Element nonceElement = document
				.createElement(WXXmlElementName.NONCE);
		nonceElement.setTextContent(this.nonce);

		xml.appendChild(encryptElement);
		xml.appendChild(msgSignatureElement);
		xml.appendChild(timeStampElement);
		xml.appendChild(nonceElement);
		return xml;
	}
	@Override
	public void read() {
		this.encrypt = getElementContent(WXXmlElementName.ENCRYPT);
	}
	//该消息不发送客服,不实现
	@Override
	public JsonObject toJson() {
		return null;
	}
	public String getEncrypt() {
		return encrypt;
	}
	public void setEncrypt(String encrypt) {
		this.encrypt = encrypt;
	}
	public String getMsgSignature() {
		return msgSignature;
	}
	public void setMsgSignature(String msgSignature) {
		this.msgSignature = msgSignature;
	}
	public String getTimeStamp() {
		return timeStamp;
	}
	public void setTimeStamp(String timeStamp) {
		this.timeStamp = timeStamp;
	}
	public String getNonce() {
		return nonce;
	}
	public void setNonce(String nonce) {
		this.nonce = nonce;
	}
}
